package com.nameless.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nameless.entity.Menu;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
* @author keluoyisi
 * @Entity com.nameless.entity.SysMenu
*/
public interface MenuMapper extends BaseMapper<Menu> {

    @Select("select distinct p.* from sys_menu p left join sys_role_menu rp on p.menu_id=rp.menu_id left join sys_user_role ur on ur.role_id=rp.role_id where ur.user_id=#{userId}")
    List<Menu> selectPermission(Integer userId);

    @Select("select distinct p.* from sys_menu p left join sys_role_menu rp on p.menu_id=rp.menu_id left join sys_user_role ur on ur.role_id=rp.role_id where ur.user_id=#{userId} and p.menu_type != 'F'")
    List<Menu> selectPermissionDistictF(Integer userId);

    void batchPermission(@Param("roleId") Integer roleId, @Param("menuids") Integer[] menuids);


    List<Menu> selectAll();

    List<Integer> selectRoleId(Integer roleId);
    void deleteByRoleId(Integer roleId);


}